<template>
  <div>
    <TopFilter :list="topFilterList" :cols="3" :labelWidth="90" :collapse="false" @filterChange="changeHandle" @onCollapse="collapseHandle"></TopFilter>
    <FilterTable
      ref="table1"
      :columns="columns2"
      :fetchapi="fetchApi"
      :params="fetchParams"
      :datakey="'rowsItem'"
      :isSelectColumn="false"
      :isToperInfo="false"
      :height="200"
      :onColumnsChange="columns => (this.columns2 = columns2)"
      columnsRef="zjwxlsSBaoTable2"
    >
    </FilterTable>
    <FilterTable
      ref="table2"
      :columns="columns"
      :fetchapi="fetchApi"
      :params="fetchParams"
      :datakey="'rows'"
      :isSelectColumn="false"
      :isToperInfo="false"
      :onColumnsChange="columns => (this.columns = columns)"
      columnsRef="zjwxlsSBaoTable"
    >
    </FilterTable>
    <div style="height:53px"></div>
    <div
      :style="{
        position: 'absolute',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'right'
      }"
    >
      <el-button @click="closeDrawer()">返 回</el-button>
    </div>

    <!-- <BaseDialog :visible.sync="settlementVisible" title="结算明细" destroyOnClose :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px' }">
      <settlement :getdata="settlementdata" @close="closeSpop"></settlement>
    </BaseDialog>
    <BaseDialog :visible.sync="jobVisible" title="维修明细" destroyOnClose :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px' }">
      <jobdetail :getdata="settlementdata" @close="closeJpop"></jobdetail>
    </BaseDialog> -->
  </div>
</template>
<script>
import { dictionary } from '@/utils/dictMixin';
import { getSbList, getfindAllRepairType } from '@/api/repair/business/customer/history';
import { getDealerUser } from '@/api/customerRepair/customerComplaint/customerComplaintReception';

export default {
  name: 'SBaoTable',
  mixins: [dictionary],
  props: ['setdata'],
  data() {
    this.BaseTable = null;
    return {
      fetchApi: getSbList,
      fetchParams: { VIN: this.setdata.VIN, xhrAbort: true },
      topFilterList: this.createTopFilterList(),
      columns: this.createTable(),
      columns2: this.createTable2(),
      list: []
    };
  },
  created() {},
  mounted() {
    this.BaseTable1 = this.$refs.table1.$refs.pageTable;
    this.BaseTable2 = this.$refs.table2.$refs.pageTable;
    this.changeHandle();
    // this.getEmp();
  },
  methods: {
    createTopFilterList() {
      return [
        // {
        //   type: 'RANGE_DATE',
        //   label: '开单日期',
        //   fieldName: 'beginDate|endDate'
        // }
      ];
    },
    createTable2() {
      return [
        {
          title: '总成/系统以及零部件',
          dataIndex: 'mainPart',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '故障代码',
          dataIndex: 'TroubleCode',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '次数',
          dataIndex: 'frequency',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '按“总成”汇总',
          dataIndex: 'Assembly',
          sorter: true,
          filter: true,
          filterType: 'input'
        }
      ];
    },
    createTable() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '工单号',
          dataIndex: 'RoNo',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '超期原因',
          dataIndex: 'DelayReason',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '审核日期',
          dataIndex: 'AuditDate',
          sorter: true,
          filter: true,
          dateFormat: 'yyyy-MM-dd HH:mm:ss',
          filterType: 'date-range'
        },
        {
          title: '维修类型',
          dataIndex: 'RoType',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '主要零部件',
          dataIndex: 'MainSpaName',
          sorter: true,
          editType: 'checkbox',
          editItems: [
            { text: '', trueValue: '10041001' },
            { text: '', falseValue: '10041002' }
          ]
        },
        {
          title: '总成名称',
          dataIndex: 'AssemName',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '次要零部件',
          dataIndex: 'SubSpaName',
          sorter: true,
          editType: 'checkbox',
          editItems: [
            { text: '', trueValue: '10041001' },
            { text: '', falseValue: '10041002' }
          ]
        },
        {
          title: '是否SA',
          dataIndex: 'IfSa',
          sorter: true,
          editType: 'checkbox',
          editItems: [
            { text: '', trueValue: '10041001' },
            { text: '', falseValue: '10041002' }
          ]
        },
        // {
        //   title: '是否SA',
        //   dataIndex: 'IfSa',
        //   sorter: true,
        //   editType: 'checkbox',
        //   editItems: [
        //     { text: '', trueValue: '10041001' },
        //     { text: '', falseValue: '10041002' }
        //   ]
        // },
        {
          title: '故障描述',
          dataIndex: 'TroubleType',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '故障代码',
          dataIndex: 'TroubleCode',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '开始日期',
          dataIndex: 'StartDate',
          sorter: true,
          filter: true,
          dateFormat: 'yyyy-MM-dd HH:mm:ss',
          filterType: 'date-range'
        },
        {
          title: '结算日期',
          dataIndex: 'BalanceDate',
          sorter: true,
          filter: true,
          dateFormat: 'yyyy-MM-dd HH:mm:ss',
          filterType: 'date-range'
        },
        {
          title: '车牌号',
          dataIndex: 'LicenseNo',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '位置码',
          dataIndex: 'PosCode',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '是否ZY',
          dataIndex: 'IfZy',
          sorter: true,
          editType: 'checkbox',
          editItems: [
            { text: '', trueValue: '10041001' },
            { text: '', falseValue: '10041002' }
          ]
        },
        {
          title: '是否为FIB',
          dataIndex: 'F_I_B',
          sorter: true,
          editType: 'checkbox',
          editItems: [
            { text: '', trueValue: '10041001' },
            { text: '', falseValue: '10041002' }
          ]
        },
        {
          title: '超期原因其他说明',
          dataIndex: 'DelayReasonEtc',
          sorter: true,
          filter: true,
          filterType: 'input'
        }
      ];
    },
    closeDrawer() {
      this.$emit('close', false);
    },
    // 搜索
    changeHandle(val) {
      if(!this.setdata.VIN){
        this.$notify.warning({ title: '提示信息', message: '请输入VIN' });
      }else{
        this.fetchParams = Object.assign({}, val, { xhrAbort: false, vin: this.setdata.VIN });
      }
    },
    collapseHandle() {
      this.$nextTick(() => {
        this.BaseTable1.EXECUTE_RESET_HEIGHT();
        this.BaseTable2.EXECUTE_RESET_HEIGHT();
      });
    }
    // 获取全部员工
    // async getEmp() {
    //   const res = await getDealerUser();
    //   let empList = res.data.map(x => ({ text: x.employeeName, value: x.userId + '' }));
    //   this.columns.find(item => item.dataIndex === 'service_advisor').editItems = empList; // 服务顾问
    // }
  }
};
</script>
